package com.lottery.system.common.exception;

import com.lottery.system.common.errorcode.ErrorCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * program: lottery-system
 * description: 业务逻辑层的异常
 * @author: xiaoxie
 * create: 2024-08-27 22:23
 **/
@EqualsAndHashCode(callSuper=true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ServiceException extends RuntimeException{
    /**
     * 错误码
     * @see com.lottery.system.common.errorcode.ServiceErrorCodeConstants
     */
    private Integer code;

    /**
     * 错误信息
     */
    private String msg;

    public ServiceException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.msg = errorCode.getMsg();
    }
}